import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { boolean } from "../engine/validators/boolean";
import { number } from "../engine/validators/number";
import { string } from "../engine/validators/string";
import { GameObjectAcitivable } from "./GameObjectAcitivable";

export class SceneChange extends Behaviour {

    @boolean()
    isSatisfied =false;
    
    @string()
    destination1 = "";

    @string()
    destination2 = "";

    @string()
    destination3 = "";

    @string()
    destination4 = "";

    @string()
    destination5 = "";

    @string()
    destination6 = "";

    @string()
    destination7 = "";

    @string()
    destination8 = "";

    onStart():void{
        this.gameObject.onClick= () =>{
            const scene1 = getGameObjectById(this.destination1).getBehaviour(GameObjectAcitivable).IsActive;
            const scene2 = getGameObjectById(this.destination2).getBehaviour(GameObjectAcitivable).IsActive;
            if(scene1 === true && scene2 === false){
                getGameObjectById(this.destination1).getBehaviour(GameObjectAcitivable).IsActive=false;
                getGameObjectById(this.destination2).getBehaviour(GameObjectAcitivable).IsActive=true;
            }

            if(scene2 === true && scene1 === false){
                getGameObjectById(this.destination1).getBehaviour(GameObjectAcitivable).IsActive=true;
                getGameObjectById(this.destination2).getBehaviour(GameObjectAcitivable).IsActive=false;
            }
        }

    }
}